package com.itheima.sh.clients;

import com.itheima.sh.clients.fallback.UserFeignApiFallBack;
import com.itheima.sh.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @Description:
 * @Version: V1.0
 */
@Primary
@FeignClient(value = "user-service", fallback = UserFeignApiFallBack.class)  // 服务名称是从 Eureka server中获取
//@FeignClient("user-service")  // 服务名称是从 Eureka server中获取
public interface UserFeignApi {

    /**
     * 查询用户信息
     * @param username
     * @return
     *
     * 参考服务提供方编写，由服务提供方编写
     */
    @GetMapping("/user/{id}")  // 注意请求地址在类上定义的名称
    public User queryById(@PathVariable("id") String username);
}
